﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KTV项目
{
    public partial class xiugai : Form
    {
        Bestdao dao = new Bestdao();
        public xiugai()
        {
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
        //创建一个变量来存储图片路径
        string lujing;
        private void button3_Click(object sender, EventArgs e)
        {
            //创建一个打开文件方式
            OpenFileDialog od = new OpenFileDialog();
            od.InitialDirectory = "D:\\Songs";
            od.Filter = "jpg|*.jpg|png|*.png";
            DialogResult dr = od.ShowDialog();

            if (dr==DialogResult.OK)
            {
                lujing = od.FileName;
                piclujing.ImageLocation = lujing;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //关闭本窗体
            this.Close();
        }

        private void xiugai_Load(object sender, EventArgs e)
        {
            //将数据库的歌手类别绑定到下拉框中显示
            string sql = "select singertype_id,singertype_name from singer_type";
            comtype.DataSource = dao.table(sql);
            comtype.DisplayMember = "singertype_name";
            comtype.ValueMember = "singertype_id";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //将窗体获得的修改后的歌手信息创建SQL语句更新数据库中的信息
            string sql = string.Format(@"update singer_info set singer_name='{0}',singertype_id={1},singer_sex='{2}',singer_photo_url='{3}',singer_miao='{4}'
where singer_id={5}",tebname.Text,comtype.SelectedIndex+1,texsex.Text,lujing,texmiao.Text,texid.Text);
            int he = dao.query(sql);
            if (he!=0)
            {
                MessageBox.Show("修改成功","提示");
                this.Close();
            }
            else
            {
                MessageBox.Show("修改失败","提示");
            }
           
        }
    }
}
